package demo;

import java.util.*;

/**
 * Created by yezhengle on 2017/7/28.
 */
public class H_19 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            String data = scanner.nextLine();
            String[] numbers = data.split(" ");
            if(numbers.length !=5 || !validate(numbers) ) {
                System.out.println("重新输入");
            }else{
                String[] numberResult = generate();
                System.out.println(Arrays.toString(numbers));
                System.out.println(Arrays.toString(numberResult));
                juage(numbers, numberResult);
            }


        }
    }

    private static void juage(String[] numbers, String[] numberResult) {
        int sum = 0;
        for(int i=0; i<5; i++){
            if(numbers[i].equals(numberResult[i])){
                sum ++;
            }
        }
        switch (sum){
            case 5: System.out.println(1);
                break;
            case 4:System.out.println(2);
                break;
            case 3:System.out.println(3);
                break;
            case 2:System.out.println(4);
                break;
            case 1:
                System.out.println(5);
                break;
            default:
                System.out.println("谢谢惠顾");
                break;
        }
    }

    private static String[] generate() {
        String[] numbers = new String[5];
        List<String> numberSet = new ArrayList<>();
        for (int i=1; i<=30; i++){
            numberSet.add(Integer.toString(i));
        }
        Collections.shuffle(numberSet);
        for(int i=0; i<5; i++){
            System.out.println(numberSet.get(i));
            numbers[i] = numberSet.get(i);
            numberSet.remove(i);
        }
        return numbers;


    }

    private static boolean validate(String[] numbers) {
        if(numbers == null || numbers.length == 0){
            return false;
        }
        Set<String> numberSet = new HashSet<>();
        int sum = 0;
        for (String number: numbers) {
            if(number.matches("[1-9]|[1,2][0-9]|[3][0]") && !numberSet.contains(number)){
                numberSet.add(number);
                sum++;
            }
        }
        if (sum == 5){
            return true;
        }

        return false;
    }
}
